import {
  mapGetters
} from 'vuex'
export default {

  computed: {
    ...mapGetters('m_cart', ['total'])
  },
  onShow() {
    this.setBadge()
  },
  methods: {
    // 为tabbar页面设置数字徽标
    setBadge() {
      uni.setTabBarBadge({
        index: 2,
        text: this.total + '' //text的值必须是字符串 
      })
    }
  },
  watch: {
    // 删除时购物车徽标不变化，做监听total     
    total() {
      this.setBadge()
    }
  },
}
